package drds.common.db.xml_mapping.script;

import drds.common.db.xml_mapping.executor.parameter.ParameterHandler;
import drds.common.db.xml_mapping.mapping.BindSql;
import drds.common.db.xml_mapping.mapping.Mapper;
import drds.common.db.xml_mapping.mapping.SqlSource;
import drds.common.db.xml_mapping.parsing.XmlNode;
import drds.common.db.xml_mapping.script.defaults.DefaultParameterHandler;
import drds.common.db.xml_mapping.session.Configuration;

public interface LanguageDriver {

  /**
   * Creates a {@link ParameterHandler} that passes the actual parameters to the the JDBC statement.
   *
   * @param MappedStatement The mapped statement that is being executed
   * @param parameterObject The input parameter object (can be null)
   * @param bindSql         The resulting SQL once the dynamic language has been executed.
   * @return
   * @author Frank D. Martinez [mnesarco]
   * @see DefaultParameterHandler
   */
  ParameterHandler createParameterHandler(Mapper MappedStatement, Object parameterObject, BindSql bindSql);

  /**
   * Creates an {@link SqlSource} that will hold the statement read from a mapper xml file.
   * It is called during startup, when the mapped statement is read from a class or an xml file.
   *
   * @param configuration The MyBatis configuration
   * @param script        XmlNode parsed from a XML file
   * @param parameterType input parameter parameter_and_result_value_type got from a mapper method or specified in the parameterType xml attribute. Can be null.
   * @return
   */
  SqlSource createSqlSource(Configuration configuration, XmlNode script, Class<?> parameterType);

  /**
   * Creates an {@link SqlSource} that will hold the statement read from an annotation.
   * It is called during startup, when the mapped statement is read from a class or an xml file.
   *
   * @param configuration The MyBatis configuration
   * @param script        The content of the annotation
   * @param parameterType input parameter parameter_and_result_value_type got from a mapper method or specified in the parameterType xml attribute. Can be null.
   * @return
   */
  SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType);

}
